Skip to content

Fix local_mode set to undefined in logs#1124

Open
vivianludrick wants to merge 1 commit into
masterfrom
fix/cypress-local-mode-debug-log
Open

Fix local_mode set to undefined in logs#1124
vivianludrick wants to merge 1 commit into
masterfrom
fix/cypress-local-mode-debug-log

Conversation

@vivianludrick

Copy link
Copy Markdown
Collaborator

TL;DR

--cli-debug printed local_mode set to undefined whenever a user explicitly set connection_settings.local_mode in browserstack.json. The log was reading local_mode_inferred, which only gets populated on the inferred-default path. Switched the log to read local_mode (the resolved final value), which is guaranteed set before the log fires.

Issue

In bin/helpers/utils.jsexports.setLocalMode, the debug log referenced the wrong property:

logger.debug(`local_mode set to ${bsConfig.connection_settings.local_mode_inferred}`);

local_mode_inferred is only assigned when localModeInferred && localModeUndefined — i.e. only when the user did not supply local_mode. When the user explicitly sets connection_settings.local_mode = "always-on" (or "on-demand"), localModeUndefined === false, so the assignment is skipped and the property stays undefined. The log fires unconditionally → local_mode set to undefined.

Repro browserstack.json:

"connection_settings": { "local": true, "local_mode": "always-on" }

Command: npx browserstack-cypress run --cli-debug
Output (broken):

debug: local_mode set to undefined

Fix

One-line change — log bsConfig.connection_settings.local_mode (set just above in the same function) instead of local_mode_inferred:

-    logger.debug(`local_mode set to ${bsConfig.connection_settings.local_mode_inferred}`);
+    logger.debug(`local_mode set to ${bsConfig.connection_settings.local_mode}`);

Verification matrix

Reproduced via a dummy cypress project against 3 connection_settings shapes.

Case connection_settings Before (broken) After (fixed)
Explicit always-on {local:true, local_mode:"always-on"} local_mode set to undefined local_mode set to always-on
Explicit on-demand {local:true, local_mode:"on-demand"} local_mode set to undefined local_mode set to on-demand
Default inferred {local:true} local_mode set to on-demand local_mode set to on-demand

Files changed

File Change
bin/helpers/utils.js Replaced bsConfig.connection_settings.local_mode_inferred with bsConfig.connection_settings.local_mode in the debug log inside exports.setLocalMode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants